---

- name: init java-application directory
  ansible.builtin.file:
    path: /app/
    state: directory
    
- name: Install java-21-openjdk
  ansible.builtin.dnf:
    name: java-21-openjdk
    state: latest

- name: Copy service starter
  ansible.builtin.copy:
    src: service-starter.sh
    dest: /app/service-starter.sh
    mode: 0755

- name: copy gateway-application service
  ansible.builtin.copy:
    src: java-application.service
    dest: /etc/systemd/system/java-application.service

- name: Enable and restart java-application service
  ansible.builtin.service:
    name: java-application
    daemon_reload: true
    state: restarted
    enabled: yes
